<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Comment;
class CommentController extends Controller
{
    //
    //
    public function index(){
        $comm=Comment::paginate(15);
        return $comm;
    }
    public function edit($id){
        return Comment::find($id);
    }
    public function destroy($id){
        if(Comment::find($id)->delete()){
            echo '删除成功';
        }       
    }
    public function update(Request $req){
        $user=Comment::find($req->id);
        $user->body=$req->body;
        //return '更新成功';
        if($user->save()){
            echo '数据更新成功！';
        }
    }
     public function batchdestroy(Request $req){
        $ids=explode(',',$req->ids);
        foreach ($ids as $id){
            Comment::find($id)->delete();
        }
        echo '删除成功';
    }
}
